package 剑指offer.第4天;

/**
 * 剑指 Offer 53 - I. 在排序数组中查找数字 I
 统计一个数字在排序数组中出现的次数。
 示例 1:
 输入: nums = [5,7,7,8,8,10], target = 8
 输出: 2
 */
class Solution2 {
    public int search(int[] nums, int target) {
        int num = 0;
        for (int i = 0; i < nums.length; i++) {
            if (target == nums[i]) {
                num++;
            }
        }
        return num;
    }
    public static void main(String[] args) {
        int[] nums = {5,7,7,8,8,10};
        int target = 8;
        int s1 = new Solution2().search(nums, target);
        System.out.println("s1 = " + s1);

    }
}